<template>
  <div class="expressedit">
    <el-dialog
      :title="text"
      :visible.sync="dialogExpress"
      width="40%">
      <el-form :model="form" ref="form" size="medium" label-width="120px">
        <el-form-item label="公司名称:" prop="express">
          <el-input v-model="form.express" placeholder="请输入公司名称"></el-input>
        </el-form-item>
        <el-form-item label="编目:" prop="catalog">
          <el-input v-model="form.catalog" placeholder="请输入编目"></el-input>
        </el-form-item>
        <el-form-item label="是否启用:" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio :label="1">隐 藏</el-radio>
            <el-radio :label="0">启 用</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="save">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name:'ExpressEdit',
    props:{
      rows: {}
    },
    data() {
      return {
        text: '',
        dialogExpress: false,
        form: {
          express: '',
          catalog: '',
          status: ''
        }
      }
    },
    methods: {
      //打开弹窗-编辑
      openEdit() {
        this.dialogExpress = true;
        this.text = "编辑物流公司"
        this.form = {
          express: this.rows.express,
          catalog: this.rows.catalog,
          status: this.rows.status
        }
        console.log('form',this.form)
      },
      //打开弹窗-新增
      openAdd() {
        this.dialogExpress = true;
        this.text = "添加物流公司"
      },

      //保存
      save () {
        this.$refs['form'].validate(valid => {
          if (valid) {
            console.log('form1',this.form)
            this.dialogExpress = false;
            this.form = {
              express: '',
              catalog: '',
              status: ''
            };
            console.log('form2',this.form)
            this.$message.success('保存成功')
          } else {
            this.$message.error('表单验证失败!')
          }
        })
      },

      //关闭
      close() {
        this.dialogExpress = false;
        this.form = {
          express: '',
          catalog: '',
          status: ''
        }
      }
    }
  }
</script>

<style>
</style>
